package com.swind.fast.modules.app.railway.project.service.impl;

import org.springframework.beans.factory.annotation.Autowired;

import com.swind.fast.common.system.base.service.impl.SwindServiceImpl;
import com.swind.fast.modules.app.railway.project.entity.RailwayProjectWorkTask;
import com.swind.fast.modules.app.railway.project.mapper.RailwayProjectWorkTaskMapper;
import com.swind.fast.modules.app.railway.project.service.IRailwayProjectWorkTaskService;
import com.swind.fast.modules.app.railway.project.service.IRailwayProjectTaskPointService;
import com.swind.fast.modules.app.railway.project.vo.RailwayDataManagementStatisticVo;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import org.springframework.stereotype.Service;

/**
 * @Description: 项目
 */
@Service
public class RailwayProjectWorkTaskServiceImpl extends SwindServiceImpl<RailwayProjectWorkTaskMapper, RailwayProjectWorkTask> implements IRailwayProjectWorkTaskService {

    @Autowired
    private IRailwayProjectTaskPointService railwayProjectTaskPointService;

    public RailwayDataManagementStatisticVo getWorkTaskStatisticByProjectId(String projectId) {
        RailwayDataManagementStatisticVo statistic = new RailwayDataManagementStatisticVo(projectId, "0", "0", "0", "0", "0");
        QueryWrapper<RailwayProjectWorkTask> queryWrapper = new QueryWrapper<RailwayProjectWorkTask>().select("id").eq("project_id", projectId);
        Integer taskCount = this.count(queryWrapper);
        statistic.setTask(String.valueOf(taskCount));
        statistic = railwayProjectTaskPointService.getWorkTestPointStatistic(statistic);

        return statistic;
    }

    @Override
    public RailwayProjectWorkTask getWorkTaskByHoleName(String projectId, String holeName) {
        QueryWrapper<RailwayProjectWorkTask> queryWrapper = new QueryWrapper<RailwayProjectWorkTask>().eq("project_id", projectId).eq("hole_name", holeName).last("limit 1");
        return this.getOne(queryWrapper);
    }
}
